/////////////////////////////////////////////////////////////////////////////
// Name:        DownloadPkgDialog.h
// Purpose:     
// Author:      yospaly
// Modified by: 
// Created:     14/01/2009 14:21:46
// RCS-ID:      
// Copyright:   Copyright (C) 2008, yospaly
// Licence:     
/////////////////////////////////////////////////////////////////////////////

#ifndef _DOWNLOADPKGDIALOG_H_
#define _DOWNLOADPKGDIALOG_H_


/*!
 * Includes
 */

////@begin includes
#include "wx/statline.h"
////@end includes

/*!
 * Forward declarations
 */

////@begin forward declarations
////@end forward declarations

/*!
 * Control identifiers
 */

////@begin control identifiers
#define ID_DOWNLOAD_PKG_DIALOG 10005
#define ID_GAUGE 10036
#define SYMBOL_DOWNLOADPKGDIALOG_STYLE wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxTAB_TRAVERSAL
#define SYMBOL_DOWNLOADPKGDIALOG_TITLE _("Downloading setup.ini ...")
#define SYMBOL_DOWNLOADPKGDIALOG_IDNAME ID_DOWNLOAD_PKG_DIALOG
#define SYMBOL_DOWNLOADPKGDIALOG_SIZE wxSize(400, 200)
#define SYMBOL_DOWNLOADPKGDIALOG_POSITION wxDefaultPosition
////@end control identifiers


/*!
 * DownloadPkgDialog class declaration
 */

class DownloadPkgDialog: public wxDialog
{    
    DECLARE_DYNAMIC_CLASS( DownloadPkgDialog )
    DECLARE_EVENT_TABLE()

public:
    /// Constructors
    DownloadPkgDialog();
    DownloadPkgDialog( wxWindow* parent, wxWindowID id = SYMBOL_DOWNLOADPKGDIALOG_IDNAME, const wxString& caption = SYMBOL_DOWNLOADPKGDIALOG_TITLE, const wxPoint& pos = SYMBOL_DOWNLOADPKGDIALOG_POSITION, const wxSize& size = SYMBOL_DOWNLOADPKGDIALOG_SIZE, long style = SYMBOL_DOWNLOADPKGDIALOG_STYLE );

    /// Creation
    bool Create( wxWindow* parent, wxWindowID id = SYMBOL_DOWNLOADPKGDIALOG_IDNAME, const wxString& caption = SYMBOL_DOWNLOADPKGDIALOG_TITLE, const wxPoint& pos = SYMBOL_DOWNLOADPKGDIALOG_POSITION, const wxSize& size = SYMBOL_DOWNLOADPKGDIALOG_SIZE, long style = SYMBOL_DOWNLOADPKGDIALOG_STYLE );

    /// Destructor
    ~DownloadPkgDialog();

    /// Initialises member variables
    void Init();

    /// Creates the controls and sizers
    void CreateControls();

////@begin DownloadPkgDialog event handler declarations

    /// wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
    void OnCANCELClick( wxCommandEvent& event );

////@end DownloadPkgDialog event handler declarations

////@begin DownloadPkgDialog member function declarations

    /// Retrieves bitmap resources
    wxBitmap GetBitmapResource( const wxString& name );

    /// Retrieves icon resources
    wxIcon GetIconResource( const wxString& name );
////@end DownloadPkgDialog member function declarations

    /// Should we show tooltips?
    static bool ShowToolTips();

////@begin DownloadPkgDialog member variables
    wxStaticText* p_download_info_static;
    wxStaticText* p_total_size_static;
    wxStaticText* p_file_name_static;
    wxStaticText* p_file_size_static;
    wxStaticText* p_speed_static;
    wxStaticText* p_downloaded_static;
    wxGauge* p_download_gauge;
    wxButton* p_ok_button;
////@end DownloadPkgDialog member variables
    
public:
	void OnPkgDownloadBegin(wxCommandEvent &event);
	void OnPkgDownloading(wxCommandEvent &event);
	void OnPkgDownloadCompleted(wxCommandEvent &event);
	void OnPkgsDownloadBegin(wxCommandEvent &event);
	void OnPkgsDownloadCompleted(wxCommandEvent &event);
	
protected:
	unsigned long _total_size;
	unsigned long _cur_size;
	unsigned long _speed;
	unsigned long _downloaded;
	unsigned long _total_downloaded;
	wxString _cur_file_name;
	
	wxStopWatch _watch;
	
	bool _refresh_status();
};

#define _DOWNLOAD_STATUS_FMT_STRING _("Downloading packages from : %s\n" \
		"Toltal Size : %s\n" \
		"Current file name : %s\n" \
		"Current file size : %s\n" \
		"Speed : %s/s\n" \
		"Downloaded : %s")

#endif
    // _DOWNLOADPKGDIALOG_H_
